package com.wxq.demo.controller;

import com.wxq.demo.pojo.Book;
import com.wxq.demo.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BookController {
    @Autowired
    BookService bookService;

    @GetMapping("/bookOps")
    public void bookOps() {
        Book book1 = new Book();
        book1.setName("西厢记");
        book1.setAuthor("王实甫");
        System.out.println("addBook>>>>" + bookService.addBook(book1));
        Book book2 = new Book();
        book2.setId(1);
        book2.setName("朝花夕拾");
        book2.setAuthor("鲁迅");
        System.out.println("updateBook>>>>" + bookService.updateBook(book2));
        System.out.println("getBookById>>>>" + bookService.getBookById(1));
        System.out.println("deleteBookById>>>>" + bookService.deleteBook(2));
        System.out.println("getAllBooks>>>>" + bookService.getAllBooks());
    }
}
